RECHARGE_SUB_TYPE_DCT = {
    'unionagency': {'name': "Unionagency"},
    'justpay': {'name': "Justpay"},
    'wechat': {'name': "微信代理充值"},
    'mf_pay': {"name": '秒付'}
}

WITHDRAW_STATUS_DCT = {
    2: {'name': '成功'},
    4: {'name': '失败'}
}


EVENT_RULES = {
    "aggs": {
        "groups": [
            {
                "group_name": "充值类型／充值通道",
                "field_id": "recharge_recharge_type",
                "is_keyword": True,
                "field_name": "充值类型",
                "sub_fields": [
                    {
                        "field_id": "recharge_recharge_channel",
                        "is_keyword": False,
                        "field_name": "充值通道"
                    },
                ]
            },
            {
                "group_name": "渠道",
                "field_id": "_chn",
                "is_keyword": True,
                "field_name": "渠道"
            }

        ],
        "values": [
            {
                "value_id": "recharge_price",
                "fmt": "\"%.2f\" % a",
                "value_name": "充值金额",
                "adjust_amount": True,
            },
        ],
        "uv": {
            "field_id": "_user_id",
            "field_name": "充值人次"
        },
        "pv": {
            "field_name": "充值次数"
        }
    }
}

EVENT_CONFIG = {
    "event_id": "recharge",
    "event_name": "充值分析",
    "values": {
        "_user_id": {
            "field_name": "用戶ID",
            "value_type": "long",
            "display_priority": 1
        },
        "recharge_type": {
            "field_name": "充值類型",
            "value_type": "string",
            "enum": {
                "target_enum_dct": RECHARGE_SUB_TYPE_DCT
            },
            "display_priority": 2
        },
        "recharge_channel": {
            "field_name": "充值渠道",
            "value_type": "long",
            "required": False,
            "detail_invisible": True
        },
        "price": {
            "field_name": "充值金额",
            "value_type": "float",
            "display_priority": 3
        },
        'status': {
            "field_name": "状态",
            "value_type": "long",
            "enum": {
                "target_enum_dct": WITHDRAW_STATUS_DCT
            },
            "display_priority": 4
        },
        "third_time": {
            "field_name": "第三方完成時間",
            "value_type": "long",
            "detail_invisible": True
        },
        "_event_time": {
            "field_name": "充值完成时间",
            "value_type": "long",
            "display_priority": 5,
        },
        "apply_time": {
            "field_name": "充值申请时间",
            "value_type": "long",
            "required": False,
        }
    },
    "rule": EVENT_RULES
}
